<% layout('/layouts/default.html', {title: '评价管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-trophy"></i> ${text('评价管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${appointment}" action="${ctx}/fl/appointment/listEvaluateData" method="post" class="form-inline hide"
			data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div class="form-group">
				<label class="control-label">${text('诊所')}：</label>
				<div class="control-inline width-120">
					<#form:select path="clinic.id" items="${clinicList}" itemLabel="name" itemValue="id" blankOption="true" class="form-control "/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('科室')}：</label>
				<div class="control-inline width-120">
					<#form:select path="department" dictType="fl_department" blankOption="true" class="form-control"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('预约人手机')}：</label>
				<div class="control-inline width-100">
					<#form:input path="leaguer.cellphone" class="form-control"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('预约人姓名')}：</label>
				<div class="control-inline width-100">
					<#form:input path="leaguer.name" class="form-control"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('预约日期')}：</label>
				<div class="control-inline width-100">
					<#form:input path="scheduledTime" readonly="true" maxlength="20" class="form-control Wdate"
					dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('评价等级')}：</label>
				<div class="control-inline width-120">
					<#form:select path="evaluateLevel" dictType="fl_evaluate_level" blankOption="true" class="form-control"/>
				</div>
			</div>
			<div class="form-group">
				<button type="submit" class="btn btn-primary btn-sm" onclick="$('#pageNo').val(1);$('#searchForm').attr('action','${ctx}/fl/appointment/listEvaluateData')">${text('查询')}</button>
				<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
			</div>
			<input type="hidden" name="isEndPoorRating" value="${appointment.isEndPoorRating}"/>
		</#form:form>
		<table id="dataGrid"></table>
		<div id="dataGridPage"></div>
	</div>
</div>
</div>
<% } %>
<script>
	var isEndPoorRating = js.getParam("isEndPoorRating", location.href);
	if(isEndPoorRating){
		$(".box-tools").hide();
		$("#searchForm").hide();
    }

	function displayScore(val, obj, row, act){
	    if(val<3)
            return "<span class='text-danger'>"+val+"</span>";
        return "<span>"+val+"</span>";
    }
	// 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        columnModel: [
            {header:'${text('预约编号')}', name:'no', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){
                    return '<a href="${ctx}/fl/appointment/view?id='+row.id+'" class="btnList" data-title="${text('编辑预约')}">'+(val||row.id)+'</a>';
                }},
            {header:'${text('预约人手机')}', name:'leaguer.cellphone', width:200, align:"center"},
            {header:'${text('预约人姓名')}', name:'leaguer.name',  width:150, align:"center"},
            {header:'${text('地区')}', name:'area.areaName', width:150, align:"center"},
            {header:'${text('诊所')}', name:'clinic.name',  width:150, align:"center"},
            {header:'${text('预约日期')}', name:'scheduledTime', index:'a.scheduled_time', width:150, align:"center"},
            {header:'${text('专业性')}', name:'score1', index:'score1', width:150, align:"center", formatter:displayScore},
            {header:'${text('服务态度')}', name:'score2', index:'score2', width:150, align:"center", formatter:displayScore},
            {header:'${text('诊所环境')}', name:'score3', index:'score3', width:150, align:"center", formatter:displayScore},
            {header:'${text('时效性')}', name:'score4', index:'score4', width:150, align:"center", formatter:displayScore},
            {header:'${text('评价')}', name:'evaluateDetail', index:'evaluateDetail', width:150, align:"center"},
            {header:'${text('操作')}', name:'actions', width:170, sortable:false, title:false, formatter: function(val, obj, row, act){
                    var actions = [];
                	<% if (hasPermi('fl:appointment:evaluateView')){ %>
                    actions.push('<a href="${ctx}/fl/appointment/evaluateView?id='+row.id+'" class="btnList" title="${text('查看详细')}"><i class="fa fa-eye"></i></a>&nbsp;');
                    <% } %>
                	<% if (hasPermi('fl:appointment:evaluateEdit')){ %>
                    actions.push('<a href="#" onclick="openLayerPage(\'${ctx}/fl/evaluateDetail/form?appointment.id='+row.id+'&source=2\', \'${text('追加评论')}\', 400,400);" title="${text('追加评论')}"><i class="icon-plus"></i></a>&nbsp;');
                	if(row.isEndPoorRating=="0" && (row.score1<3 || row.score2<3 || row.score3<3 || row.score4<3))
                    	actions.push('<a href="${ctx}/fl/appointment/endPoorRating?id='+row.id+'" class="btnList" title="${text('处理差评')}" data-confirm="${text('确认要处理该差评吗？')}"><i class="fa fa-check"></i></a>&nbsp;');
                    <% } %>
                    return actions.join('');
            }}
        ],
        // 加载成功后执行事件
        ajaxSuccess: function(data){

        }
    });
</script>
